package com.lagou.module.service;

import com.lagou.module.dao.StudentDao;
import com.lagou.module.entity.PageBean;
import com.lagou.module.entity.Student;
import com.lagou.module.factory.DaoFactory;

import java.util.List;

public class StudentServiceImpl implements StudentService {

    //自定义成员变量
    private StudentDao studentDao;

    //自定义构造方法 实现变量初始化


    public StudentServiceImpl() {
        this.studentDao = DaoFactory.getStudentDao();
    }


    //show all students
    @Override
    public List<Student> studentShowService(PageBean pageBean) {
        return studentDao.studentShow(pageBean);
    }

    //add student service
    @Override
    public int studentAddService(Student student) {
        return studentDao.studentAdd(student);
    }

    //delete a student
    @Override
    public int studentDeleteService(String[] ids) {
        return studentDao.studentDelete(ids);
    }

    @Override
    public int studentModifyService(Student student) {
        return studentDao.studentModify(student);

    }

    @Override
    public Student studentFindService(int id) {
        return studentDao.studentFind(id);
    }

    @Override
    public Student studentFindByClassIdService(int classId) {
        return studentDao.studentFindByClassId(classId);
    }
}
